package com.sk.bilibili.controller;

import com.sk.bilibili.other.R;
import com.sk.bilibili.service.SingletonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author 邵康
 * @date 2021/12/5 21:40
 */
@Api(tags = "对应只有一个的特殊资源的处理")
@CrossOrigin
@RestController
@RequestMapping("/singleton")
public class SingletonController {

    @Autowired
    private SingletonService singletonService;

    @ApiOperation("获取直播背景信息")
    @GetMapping("/getLiveBg")
    public R<String> getLiveBg(){
        return singletonService.getLiveBg();
    }

    @ApiOperation("更新直播背景信息")
    @PostMapping("/updateLiveBg")
    public R<Void> updateLiveBg(MultipartFile liveBg){
        return singletonService.updateLiveBg(liveBg);
    }

    @ApiOperation("获取公告信息")
    @GetMapping("/getAnnouncement")
    public R<Map<String,Object>> getAnnouncement(){
        return singletonService.getAnnouncement();
    }

    @ApiOperation("更新公告图片")
    @PostMapping("/updateAnnouncementBg")
    public R<Void> updateAnnouncementBg(MultipartFile announcementBg){
        return singletonService.updateAnnouncementBg(announcementBg);
    }

    @ApiOperation("更新公告内容 上传一个 html文件  样式尽量内敛  也可以引用其他文件")
    @PostMapping("/updateAnnouncement")
    public R<Void> updateAnnouncement(MultipartFile announcement){
        return singletonService.updateAnnouncement(announcement);
    }

}
